package cn.udrm.water.base.v1.waterdelivery.repository;

import javax.validation.constraints.NotNull;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.EntityGraph.EntityGraphType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import cn.udrm.water.base.v1.waterdelivery.entities.CanalSystemExt;

@Repository
public interface CanalSystemExtRepository extends JpaRepository<CanalSystemExt, String>
			, JpaSpecificationExecutor<CanalSystemExt>{

	@EntityGraph(value="CanalSystemExt.canalSystem", type=EntityGraphType.FETCH)
	public Page<CanalSystemExt> findAll(@NotNull Specification<CanalSystemExt> specification, Pageable pageable);
	
	@Query(value="FROM CanalSystemExt w WHERE w.id=?1")
	@EntityGraph(value="CanalSystemExt.canalSystem", type=EntityGraphType.FETCH)
	public CanalSystemExt findAllById(String id);
}
